<div class="action-dialog-model-fixed-body">
<div class="detailsBox">
<div class="openBox">
	<div class="detaiTab">
	 <form  name="module" id="sponsorForm" action="<@url value='/customerInfo/rest/update'/>" method ='post'   class="action-ajax-form action-ajax-form-valid action-ajax-form-confirm" action-ajax-form-confirm-message="确认提交">
		<table width="100%" cellspacing="0" cellpadding="0" border="0">
           <tbody>
   					<tr>
                        <td width="15%" align="right" class="bg">借款人姓： </td>
                        <td width="35%">${customer.user_surname} </td>
                        <td width="15%" align="right" class="bg">证件类型：</td>
                        <td>
							<#if "${customer.document_type}" ==	 "IDC" > 
							个人居民身份证
							<#elseif "${customer.document_type }" ==	 "PAS"> 
							个人护照
							<#elseif "${customer.document_type }" ==	 "GPAS"> 
							个人港澳居民来往内地通行证（香港）
							<#elseif "${customer.document_type }" ==	 "APAS"> 
							个人港澳居民来往内地通行证（澳门）
							<#elseif "${customer.document_type }" ==	 "OTH"> 
							其他
							</#if>
						</td>
                    </tr>
                     <tr>
                        <td width="15%" align="right" class="bg">借款人名：</td>
                        <td width="35%">${customer.user_name}</td>
                        <td width="15%" align="right" class="bg">证件号码:</td>
                        <td id="document_no2">${customer.document_no} </td>
                    </tr>
                    <tr>
				   <td width="15%" align="right" class="bg">借款人姓拼音:</td>
					<td width="35%">
						<input type="text" name="surnamePinyin" value="${customer.customerFamilyNamePy}" 	
						class="tabInp action-valid-field" data-action-valid-rule="required;" data-action-valid-msg-required="借款人姓拼音不能为空！"
								 autocomplete="off"/>
								 <span><font color="red">*</font></span>
								<span class="action-field-error" for="surnamePinyin" style="color: red;"></span>	
					</td>
					<td width="15%" align="right" class="bg">借款人名拼音:</td>
					<td width="35%">
						<input type="text" name="namePinyin" value="${customer.customerGivenNamePy}" 	
						class="tabInp action-valid-field" data-action-valid-rule="required;" data-action-valid-msg-required="借款人名拼音不能为空！"
								 autocomplete="off"/>
								 <span><font color="red">*</font></span>
								<span class="action-field-error" for="namePinyin" style="color: red;"></span>	
					</td>
					
				</tr>
                     <tr>
                     <!--
                       <td width="15%" align="right" class="bg">借款人姓名拼音：</td>
                       <td width="35%"><input type="text" name="userNamePinyin" value="${customer.user_name_pinyin}"/></td>
                       -->
                       <td width="15%" align="right" class="bg">发证机构:</td>
                       
                       <td colspan="3">
                       <span class="action-form-field-group">
						        <input type="text"
						        	value="${customer.issuing_authority}"
									name="issuing_authority" class="tabInp action-valid-field"
									style="margin-bottom: 2px;"
									data-action-valid-rule="required;minlength:1;maxlength:10;reg:^.{1,10}$"
									data-action-valid-msg-reg="发证机构不能超过10个字"
									data-action-valid-msg-required="发证机构不能为空！"
									autocomplete="off" />
								<span><font color="red">*</font></span> 
								<span class="action-field-error" for="customerFamilyName" style="color: red;"></span>
					    </span> <br />
                       </td>
                    </tr>
                    
                    <tr>
                        <td width="15%" align="right" class="bg">性别 :</td>
                        <td id="sex2"></td>
                        <td width="15%" align="right" class="bg">证件有效期:</td>
                        <td>
                        <@date name="license_expiration_date"  value="${(customer.license_expiration_date?string('yyyy-MM-dd'))!''}" />
                        </td>
                    </tr>
                    
                     <tr>
						<td width="15%" align="right" class="bg">年龄:</td>
                        <td><span id="age2"></span>（岁）</td>
                        <td width="15%" align="right" class="bg">学历:</td>
                        <td>
                        	<select id="education_basic" name="education" data="${customer.education}">
                        		<option value="MDS">初中及以下</option>
                        		<option value="SHS">高中/中专</option>
                        		<option value="UNV">大专</option>
                        		<option value="UDG">本科</option>
                        		<option value="GRT">研究生</option>
                        		<option value="OTH">其它</option>
                        		<option value="DTR">博士</option>
                        		<option value="MBA">MBA</option>
                        	</select>
                        
                        </td>
                    </tr>
                    
                    <tr>
                    	<td width="15%" align="right" class="bg">婚姻状况:</td>
                        <td>
                        	<label>
                            	<#if "${customer.marital_status}" == "1" > 
								未婚   
								<#elseif "${customer.marital_status}" == "2"> 
								已婚 
								<#elseif "${customer.marital_status}" == "3">
							           离异   
					           <#elseif "${customer.marital_status}" == "4">
							          丧偶   
					           <#else>
			    				 未婚   
							   </#if> 
                            </label>
                        </td>
                        
                        <td width="15%" align="right" class="bg">微信号 :</td>
                        <td>
                        <span class="action-form-field-group">
						        <input type="text" name="wechat"
						       		value="${customer.wechat}"
									class="tabInp action-valid-field"
									data-action-valid-rule="required;"
									data-action-valid-msg-required="微信号不能为空！" /> 
									<span><font color="red">*</font></span> 
									<span class="action-field-error" for="mobileNumber" style="color: red"></span>
						    </span> <br />	
                        </td>
                    </tr>
                    <tr>
                        <td width="15%" align="right" class="bg">住宅电话:</td>
                        <td>
							<span class="action-form-field-group">
						        <input type="text" name="home_phone"
						       		value="${customer.home_phone}"
									class="tabInp action-valid-field"
									data-action-valid-rule="required;number;reg:^.{1,15}$"
									data-action-valid-msg-number="联系电话只能输入数字"
									data-action-valid-msg-required="联系电话格式不正确" /> 
									<span><font color="red">*</font></span> 
									<span class="action-field-error" for="mobileNumber" style="color: red"></span>
						    </span> <br />			
                        </td>
	                    <td width="15%" align="right" class="bg">联系电话 :</td>
                        <td><input name="userPhone" id="userPhone" type="text" value="${customer.user_phone}" maxlength="11"
                        			/><font color="red">*</font>
                        	
                        </td>
                    </tr>
                     <tr>
                    	<td width="15%" align="right" class="bg">单位邮编:</td>
                        <td> 
                         <span class="action-form-field-group">
						        <input type="text" name="postcode" maxlength="8" 
						       		value="${customer.postcode}"
									class="action-valid-field inputNum"
									data-action-valid-rule="required;number;"
									data-action-valid-msg-number="单位邮编只能输入数字"
									data-action-valid-msg-required="单位邮编不能为空！" /> 
									<span><font color="red">*</font></span> 
									<span class="action-field-error" for="mobileNumber" style="color: red"></span>
						    </span> <br />	
                        </td>
                        <td width="15%" align="right" class="bg">
						<span >借款人户口所在地:</span></td></td>
                        <td>
                        	<select id="borrower_census_register_basic" name="borrower_census_register" data="${customer.borrower_census_register}">
                        		<option value="CITY_INTERNAL">本市内</option>
                        		<option value="PROVINCE_INTERNAL">本省内</option>
                        		<option value="PROVINCE_EXTERNAL">省外</option>
                        	</select>
                        </td>
                    </tr>
                    <tr>
                        <tr>
							<td width="15%" align="right" class="bg">户籍地址 :</td>
							<td colspan="3">
								<select id="select_provinceId_1" name="account_province" value="${customer.account_province}" onchange="provinceOnchange(1)"></select>&nbsp;&nbsp; 
	                    		<select id="select_areaId_1" name="account_city" value="${customer.account_city}" onchange="areaOnchange(1)"></select>&nbsp;&nbsp; 
	                    		<select id="select_cityId_1" name="account_county" value="${customer.account_county}" ></select>
	                    		<input type="text" name="permanent_residence" value="${customer.permanent_residence}">
							</td>
						</tr>
                        
                    </tr>
                    <tr>
                        <td width="15%" align="right" class="bg">居住地址	:</td>
                        <td colspan="3">
							<select id="select_provinceId_2" name="recipient_province" value="${customer.recipient_province}" onchange="provinceOnchange(2)"></select>&nbsp;&nbsp; 
	                		<select id="select_areaId_2"	   name="recipient_city" value="${customer.recipient_city}" onchange="areaOnchange(2)"></select>&nbsp;&nbsp; 
	                		<select id="select_cityId_2" name="recipient_county" value="${customer.recipient_county}" ></select>
	                		<input type="text" name="recipient_address" value="${customer.recipient_address}">
					</td>
                    </tr>
                    <tr>
                        <td width="15%" align="right" class="bg">居住年限	:</td>
                        <td colspan="3">
                        <span class="action-form-field-group">
						        <input type="text" name="live_years"
						       		value="${customer.live_years}"
									class="tabInp action-valid-field"
									data-action-valid-rule="required;number;"
									data-action-valid-msg-number="居住年限只能输入数字"
									data-action-valid-msg-required="居住年限不能为空！" /> 
									<span><font color="red">*</font></span> 
									<span class="action-field-error" for="mobileNumber" style="color: red"></span>
						    </span> <br />	
                        </td>
                    </tr>
                   <#if customer.marital_status==2>
					    <tr>
						     <td width="15%" align="right" class="bg">结婚日期:</td>
						     <td colspan="3">
						       
						         <@date name="marryDate" value="${(customer.marryDate?string('yyyy-MM-dd'))!''}" /><span
										style="color: red;">*</span>
							  
						     </td>
						</tr>
			     </#if>
		        <#if customer.marital_status==3 >
			       <tr>
					    <td width="15%" align="right" class="bg">离婚日期:</td>
						<td colspan="3">					
							 <@date name="divorceDate" value="${(customer.divorceDate?string('yyyy-MM-dd'))!''}" /><span
								style="color: red;">*</span>
					    </td>
				  </tr>    
		       </#if>
                    <tr>
                        <td width="15%" align="right" class="bg">子女情况	:</td>
                        <td colspan="3">
                         <span class="action-form-field-group">
                         		<textarea style="width: 350px" name="children_info"
	                         		class="tabInp action-valid-field"
									data-action-valid-rule="required;maxlength:1000;"
									data-action-valid-msg-required="子女情况不能为空！"
									data-action-valid-msg-reg="子女情况不能超过1000个字"
	                         		>${customer.children_info} </textarea>
								<span><font color="red">*</font></span> 
								<span class="action-field-error" for="mobileNumber" style="color: red"></span>
						    </span> <br />	
                        </td>
                    </tr>
                    <tr>
                        <td width="15%" align="right" class="bg">其他信息描述	:</td>
                        <td colspan="3">
                         <span class="action-form-field-group">
                         		<textarea style="width: 350px" name="other_info_desc"
	                         		class="tabInp action-valid-field"
									data-action-valid-rule="maxlength:1000;"
									data-action-valid-msg-reg="其他信息描述不能超过1000个字"
	                         		>${customer.other_info_desc} </textarea>
								<span class="action-field-error" for="mobileNumber" style="color: red"></span>
						    </span> <br />	
                        
                        </td>
                    </tr>
			   </tbody>
          </table>
          
          <input type="hidden" name="loan_user_id" value="${customer.loan_user_id} "/>
           <input type="hidden" name="marital_status" value="${customer.marital_status} "/>
          <div class="clearfix" align="center"> 
                 <button type="submit" class="btn_auto_30 btn_blue mtb20">保存</button>
		  </div>
		</form>  
		
		
	</div> 
	</div>
</div>
</div>
 <@js>
	 if($('#education_basic').attr('data')){
	 	$('#education_basic').val($('#education_basic').attr('data') );
	 }
	  if($('#borrower_census_register_basic').attr('data')){
	 	$('#borrower_census_register_basic').val($('#borrower_census_register_basic').attr('data') );
	 }
	 
//省市区三级联动
	provinceLoad(1);
	provinceLoad(2);
	function provinceLoad(index){
		var provinceCode = $("#select_provinceId"+"_"+index).attr('value');
		$.ajax({
			type: "GET",
			url:"${crmUrl}/common/findProvinces",
			dataType:"jsonp",
			jsonp:"_callback",
			success:function(result){
					$("#select_provinceId"+"_"+index).empty();
					 $("#select_provinceId"+"_"+index).append("<option value=''>请选择</option>"); 
					 $("#select_areaId"+"_"+index).empty();
					 $("#select_areaId"+"_"+index).append("<option value=''>请选择</option>"); 
					 $("#select_cityId"+"_"+index).empty();
					 $("#select_cityId"+"_"+index).append("<option value=''>请选择</option>");   
					 $.each(result.data,function(key,value){
					 	if(provinceCode == value[0])
						    $("#select_provinceId"+"_"+index).append("<option value='"+value[0]+"' selected='selected'>"+value[1]+"</option>");   
						else
							$("#select_provinceId"+"_"+index).append("<option value='"+value[0]+"'>"+value[1]+"</option>");     
					 });
					 provinceOnchange(index,function(){
					 	 areaOnchange(index);
					 });
				    
		 		}
	 	});
     };
	
	
	function provinceOnchange(index,callback){
		var provinceCode = $("#select_provinceId"+"_"+index).val() || $("#select_provinceId"+"_"+index).attr('value');
		var areaCode = $("#select_areaId"+"_"+index).val() || $("#select_areaId"+"_"+index).attr('value');
		if(!provinceCode){
			 $("#select_areaId"+"_"+index).empty();
			 $("#select_areaId"+"_"+index).append("<option value=''>请选择</option>"); 
			 $("#select_cityId"+"_"+index).empty();
			 $("#select_cityId"+"_"+index).append("<option value=''>请选择</option>");   			
			 return true;
		}
		$.ajax({
			type: "GET",
			url:"${crmUrl}/common/findCityByProvinceCode",
			data:{provinceCode:provinceCode},
			dataType:"jsonp",
			jsonp:"_callback",
			success:function(result){
					 $("#select_areaId"+"_"+index).empty();
					 $("#select_areaId"+"_"+index).append("<option value=''>请选择</option>"); 
					 $("#select_cityId"+"_"+index).empty();
					 $("#select_cityId"+"_"+index).append("<option value=''>请选择</option>");   
					 $.each(result.data,function(key,value){
					 	if(areaCode == value[0])
						    $("#select_areaId"+"_"+index).append("<option value='"+value[0]+"' selected='selected'>"+value[1]+"</option>");   
						else
					 		$("#select_areaId"+"_"+index).append("<option value='"+value[0]+"'>"+value[1]+"</option>");   
						 
					 });
					 callback &&　callback();
		 		}
	 	});
     }
	      
	 function areaOnchange(index){
		var areaCode = $("#select_areaId"+"_"+index).val() || $("#select_areaId"+"_"+index).attr('value');
		var cityCode = $("#select_cityId"+"_"+index).val() || $("#select_cityId"+"_"+index).attr('value');
		if(!areaCode){
			$("#select_cityId"+"_"+index).empty();
		    $("#select_cityId"+"_"+index).append("<option value=''>请选择</option>");   
			return true;
		}
		$.ajax({
			type: "GET",
			url:"${crmUrl}/common/findDistrictByCityCode",
			data:{cityCode:areaCode},
			dataType:"jsonp",
			jsonp:"_callback",
			success:function(result){
				 $("#select_cityId"+"_"+index).empty();
				 $("#select_cityId"+"_"+index).append("<option value=''>请选择</option>");   
				 $.each(result.data,function(key,value){
				 	if(cityCode == value[0])
					    $("#select_cityId"+"_"+index).append("<option value='"+value[0]+"' selected='selected'>"+value[1]+"</option>");   
					else
						$("#select_cityId"+"_"+index).append("<option value='"+value[0]+"'>"+value[1]+"</option>");   
				 });
			 }
	 	});
	}
	
	
	
	
	
		 var document_no = $('#document_no2').text();
		 $('#age2').text(getAge(document_no));
		 $('#sex2').text(getSex(document_no) == 'M'? '男':'女 ');
		 
		 //根据身份证信息获取年龄
		function getSex(UUserCard){
			//获取出生日期
			UUserCard.substring(6, 10) + "-" + UUserCard.substring(10, 12) + "-" + UUserCard.substring(12, 14);
			//获取性别
			if (parseInt(UUserCard.substr(16, 1)) % 2 == 1) {
				//alert("男");
			  	return 'M';
			} else {
				//alert("女");
				return 'F';
			}
		}
		
		  function getAge(UUserCard){
			var myDate = new Date();
			var month = myDate.getMonth() + 1;
			var day = myDate.getDate();
			var age = myDate.getFullYear() - UUserCard.substring(6, 10) - 1;
			if (UUserCard.substring(10, 12) < month || UUserCard.substring(10, 12) == month && UUserCard.substring(12, 14) <= day) {
				age++;
			}
			//alert(age);
			return age;
	    }
</@js>
<@jsRender/>
